package entity;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Book extends Product implements java.io.Serializable {

	private static final long serialVersionUID = 1556658913841048358L;
	// Fields
	/** id */
	private int id;   
	private String author;   
	private String publishing; 
	private Long publishTime;  
	private String wordNumber; 
	private String whichEdtion; 
	private String totalPage;   
	private Long printTime;  
	private String printNumber;
	private String isbn;        
	private String authorSummary; 
	private String catalogue;    

	// Constructors

	/** default constructor */
	public Book() {
	}

	/** minimal constructor */
	public Book(int id, String author, String publishing, Long publishTime,
			String authorSummary, String catalogue) {
		this.id = id;
		this.author = author;
		this.publishing = publishing;
		this.publishTime = publishTime;
		this.authorSummary = authorSummary;
		this.catalogue = catalogue;
	}

	/** full constructor */
	public Book(int id, String author, String publishing, Long publishTime,
			String wordNumber, String whichEdtion, String totalPage,
			Long printTime, String isbn, String authorSummary, String catalogue) {
		this.id = id;
		this.author = author;
		this.publishing = publishing;
		this.publishTime = publishTime;
		this.wordNumber = wordNumber;
		this.whichEdtion = whichEdtion;
		this.totalPage = totalPage;
		this.printTime = printTime;
		this.isbn = isbn;
		this.authorSummary = authorSummary;
		this.catalogue = catalogue;
	}

	// Property accessors

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAuthor() {
		return this.author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getPublishing() {
		return this.publishing;
	}

	public void setPublishing(String publishing) {
		this.publishing = publishing;
	}

	public Long getPublishTime() {
		return this.publishTime;
	}
	private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	
	public String getPublishTimeAsString(){
		Date date = new Date(publishTime);
		return df.format(date);
	}
	
	public void setPublishTimeAsString(String publishTime) {
		try {
			this.publishTime = df.parse(publishTime).getTime();
		}catch(Exception e) {}
	}

	public void setPublishTime(Long publishTime) {
		this.publishTime = publishTime;
	}

	public String getWordNumber() {
		return this.wordNumber;
	}

	public void setWordNumber(String wordNumber) {
		this.wordNumber = wordNumber;
	}

	public String getWhichEdtion() {
		return this.whichEdtion;
	}

	public void setWhichEdtion(String whichEdtion) {
		this.whichEdtion = whichEdtion;
	}

	public String getTotalPage() {
		return this.totalPage;
	}

	public void setTotalPage(String totalPage) {
		this.totalPage = totalPage;
	}

	public Long getPrintTime() {
		return this.printTime;
	}
	
	public String getPrintTimeAsString(){
		Date date = new Date(printTime);
		return df.format(date);
	}
	public void setPrintTimeAsString(String printTime) {
		try {
			this.printTime = df.parse(printTime).getTime();
		}catch(Exception e) {}
	}
	public void setPrintTime(Long printTime) {
		this.printTime = printTime;
	}

	public String getIsbn() {
		return this.isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getAuthorSummary() {
		return this.authorSummary;
	}

	public void setAuthorSummary(String authorSummary) {
		this.authorSummary = authorSummary;
	}

	public String getCatalogue() {
		return this.catalogue;
	}

	public void setCatalogue(String catalogue) {
		this.catalogue = catalogue;
	}

	public String toString() {
		return "Book [id=" + id + ", publishing=" + publishing
				+ ", publishTime=" + publishTime + "]";
	}

	public String getPrintNumber() {
		return printNumber;
	}

	public void setPrintNumber(String printNumber) {
		this.printNumber = printNumber;
	}
	
	
}